import React, { useState } from 'react'
import { Button, Input, Toast, Modal } from 'antd-mobile'
import { useNavigate, useLocation } from 'react-router-dom'
import { dofinishregister } from '@/api/regist'
type Props = {}

export default function Step3({ }: Props) {
    const [value, setValue] = useState('')
    const navigate = useNavigate();
    const loc = useLocation()
    const tel = loc.state.tel;
    return (
        <div>
            <p>输入密码</p>
            <Input
                placeholder='请输入密码'
                value={value}
                onChange={val => {
                    setValue(val)
                }}
            />
            <Button color='danger' onClick={() => {
                // 调用注册接口, 成功提示, 点击确认跳转到登录页
                dofinishregister({ tel: tel, password: value }).then(res => {
                    if (res.data.code == 200) {
                        // 
                        Modal.alert({
                            content: '注册成功',
                            onConfirm: () => {
                                navigate('/login')
                            },
                        })
                    }
                })
            }}>完成</Button>
        </div>
    )
}